<?php global $user, $base_url; ?>
<div class="user-locked-wrapper">
    <div class="tabs-controller">
        <ul id="user_locked_tabs" class="tabify nav nav-tabs">
            <li class="active">
                <a href="#locker">Your Locked<span class="label"><?php print !empty($data['all_items'])
                        ? count($data['all_items']) : '0';?></span></a>
            </li>
            <li>
                <a href="#preconsolidated">Packing Soon<span class="label"><?php print !empty($data['packing_items'])
                        ? count($data['packing_items']) : '0';?></span></a>
            </li>
            <li>
                <a href="#purchaseable_consolidations">Ready for Payment<span
                        class="label"><?php print !empty($data['payment_items']) ? count($data['payment_items'])
                        : 0;?></span></a>
            </li>
            <li>
                <a href="#shipping_soon">Shipping soon<span class="label"><?php print !empty($data['shipping_items'])
                        ? count($data['shipping_items']) : '0';?></span></a>
            </li>
            <li>
                <a href="#shipped">Shipped<span class="label"><?php print !empty($data['shipped_items'])
                        ? count($data['shipped_items']) : '0';?></span></a>
            </li>
        </ul>
    </div>
    <div class="tabs-content">
        <div id="locker" class="tab-pane">
            <?php if (!empty($data['all_items'])){ ?>
            <ul id="locked_items_tabs" class="tabify nav nav-tabs">
                <li class="active"><a href="#locker_items">All Items</a></li>
                <li><a href="#locker_packages">Packages</a></li>
            </ul>
            <div class="tab-pane" id="locker_items">
                <?php print theme('locked-items', array('items' => $data['all_items']));?>
            </div>
            <div class="tab-pane" id="locker_packages">
                <?php print theme('package-items', array('packages' => $data['packages'], 'items' => $data['package_items']));?>
            </div>
            <?php }else{?>
            <p>No Locker Items</p>
            <?php }?>
        </div>
        <div id="preconsolidated" class="tab-pane">
            <?php if (!empty($data['packing_items'])): ?>
            <?php print theme('locked-items', array('items' => $data['packing_items'])); ?>
            <?php else: ?>
            <p>No Pre Consolidated Consolidations</p>
            <?php endif;?>
        </div>
        <div id="purchaseable_consolidations" class="tab-pane">
            <?php if ($data['user_order']->rowCount() > 0): ?>
            <?php foreach ($data['user_order'] as $order): ?>
                <form action="<?php print $base_url . '/packages/confirm_payment';?>" method="POST"
                      name="form_confirm_payment">
                    <ul class="packages-payment">
                        <li>
                            <fieldset>
                                <legend>
                                    <?php $package_code = tvn_generate_order_id($order->oid);?>
                                    <input type="checkbox" name="packages[<?php print $order->oid;?>]" checked="checked"
                                           id="<?php print strtolower($package_code);?>"/>
                                    <label style="display: inline;"
                                           for="<?php print strtolower($package_code);?>"><?php print $package_code;?></label>
                                </legend>
                                <?php $items = node_load_multiple(explode(',', $order->nids));?>
                                <?php print theme('locked-items', array('items' => $items)); ?>
                            </fieldset>
                        </li>
                    </ul>
                    <div class="form-actions">
                        <input type="submit" name="submit" value="Payment" class="btn btn-primary btn-large"/>
                    </div>
                </form>
                <?php endforeach; ?>
            <?php else: ?>
            <p>You have no outstanding consolidations</p>
            <?php endif;?>
        </div>
        <div id="shipping_soon" class="tab-pane">
            <?php if (!empty($data['shipping_items'])): ?>
            <?php print theme('locked-items', array('items' => $data['shipping_items'])); ?>
            <?php else: ?>
            <p>No Paid Orders</p>
            <?php endif;?>
        </div>

        <div id="shipped" class="tab-pane">
            <?php if (!empty($data['shipped_items'])): ?>
            <?php print theme('locked-items', array('items' => $data['shipped_items'])); ?>
            <?php else: ?>
            <p>No Shipped Orders</p>
            <?php endif;?>
        </div>

    </div>
</div>
